package g.g.g;

import g.g.g.gamesystem.action.ActionManage;
import g.g.g.gamesystem.unit.PlayerInfo;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class GaminificationActivity extends Activity {
	TextView remainAction;
	TextView display;
	private static int throwsCount = 3;
	private final int reset = 3;
	private Button resetButton;
	private int nowPoint = 100;
	private String nowstringPoint = "100";
	private TextView pointText;
	private TextView countText;
	private TextView sumText;
	private PlayerInfo playerInfo;
	private final String PLAYER_NAME = "小林　勝";
	private TextView nameText;
	private int nowCount = 0;
	private static int sumCount;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        resetButton = (Button)findViewById(R.id.button_reset);
        remainAction = (TextView)findViewById(R.id.remainaction);
        display = (TextView)findViewById(R.id.display);
        pointText = (TextView)findViewById(R.id.text_point);
        countText = (TextView)findViewById(R.id.text_count);
        sumText = (TextView)findViewById(R.id.sum_text);
        countText.setText("3");
        nameText = (TextView)findViewById(R.id.name_text);
        nameText.setText(PLAYER_NAME);

        remainAction.setText("");
        pointText.setText(nowstringPoint);

        resetButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				throwsCount = reset;
				countText.setText("3");
				Toast.makeText(GaminificationActivity.this, "Resetしました", Toast.LENGTH_SHORT).show();
			}
		});
    }

    public void onClickThrowDice(View v){
    	if(throwsCount <= 0){
    		Toast.makeText(this, "これ以上ダイスは振れません", Toast.LENGTH_SHORT).show();
    	}else{
    		display.setText(throwDice());
    		throwsCount --;
    		countText.setText(String.valueOf(throwsCount));
    		sumText.setText(String.valueOf(sumCount));

    	}
    }

    public int getRemainTimes(){
    	return 123;
    }
    public String throwDice(){
    	int i = ActionManage.throwDice();
    	sumCount = sumCount + i;
    	String s = String.valueOf(i);
    	countText.setText(s);
    	return s;
    }
}